package com.example.service.impl;

import com.example.mapper.torqueManageMapp;
import com.example.pojo.siteInfoPojo;
import com.example.pojo.torqueManagePojo;
import com.example.service.torqueManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * ClassName:torqueManageImpl
 * Description:
 *
 * @Author 赵永峰
 * @Create 2024/8/8 1:28
 * @Version 1.0
 */
@Service
public class torqueManageImpl implements torqueManageService {
    @Autowired
    private torqueManageMapp torqueManageMapp;
    //按照需求数量，查询出对应的条数，是用在指定了拧紧项目、机型、工序号、需求数量等信息后查询
    public List<torqueManagePojo> inquiryDataTorque(Map<String, Object> parameters){
        int selectNum=(int)parameters.get("selectNum");
        String project=(String)parameters.get("project");
        String op=(String)parameters.get("op");
        String engineType=(String)parameters.get("engineType");
        List<torqueManagePojo> torqueManagePojoList=torqueManageMapp.inquiryDataTorque(selectNum,project,op,engineType);
        return torqueManagePojoList;
    }
    //向过站信息中查询数据：根据开始日期、终止日期，和一个机型的字符串，是一个数组形式，向过站信息中查询信息
    public List<siteInfoPojo> siteInfoStartDateByEndDate(Map<String, Object> map){
        String starDate=(String) map.get("starDate");
        String endDate=(String) map.get("endDate");
        String typesStr=(String) map.get("type");
        String op=(String) map.get("op");
        String[] types = typesStr.split("/");
        List<siteInfoPojo> allSiteInfoPojos = new ArrayList<>();
        for (int i = 0; i < types.length; i++) {
            List<siteInfoPojo> siteInfoPojos=torqueManageMapp.siteInfoStartDateByEndDate(starDate,endDate,"EB05",op);
            allSiteInfoPojos.addAll(siteInfoPojos);
        }

        return allSiteInfoPojos;
    }
}
